{template header}

    <div class="box">

        <!--{if $a == 'index'}-->
        {template title}
        <table cellpadding="1" cellspacing="1" width="100%" border="0">
            <tr>
                <th>标题</th>
                <th width="10%">时间</th>
                <th width="12%">操作</th>
            </tr>

        <!--{if $this->sort}-->
            <!--{loop $this->sort $val}-->
            <tr>
                <td class="td2 subject{$val['node']}">
                    <a href="{$this->url($c, 'edit', array('id' => $val['id'], 'type' => $val['model']))}">{$val['title']}</a>
                </td>
                <td>{echo formatDate($val['dateline'])}</td>
                <td>
                    <div class="btn-group">
                        <a title="编辑{$this->name}" class="btn btn-mini" href="{$this->url($c, 'edit', array('id' => $val['id'], 'type' => $val['model']))}">编辑</a>
                    </div>
                    <div class="btn-group">
                        <a title="删除{$this->name}" class="del btn btn-mini btn-danger" href="{$this->url($c, 'del', array('id' => $val['id'], 'type' => $val['model']))}">删除</a>
                    </div>
                </td>
            </tr>
            <!--{/loop}-->
        <!--{else}-->
            <tr>
                <td colspan="3">没有{$this->name}!</td>
            </tr>
        <!--{/if}-->
            <tr>
                <td colspan="3"><a class="btn btn-success" href="{$this->url($c, 'add', array('type' => $this->type) )}">添加{$this->name}</a></td>
            </tr>
        </table>
    <!--{/if}-->
    <!--{if $a == 'add' || $a == 'edit' }-->
    <form method="post" action="{$this->url($c, 'save', array('id' => $result['id']))}">
        <input type="hidden" name="{$c}[model]" value="{$this->type}" />
        <input type="hidden" name="{$c}[uid]" value="{$this->admin['id']}" />
        <input type="hidden" name="attach[id]" value="" />
        <table cellpadding="1" cellspacing="1" width="100%" border="0">
            <tr>
                <td width="25%">{$this->name}名称：</td>
                <td class="td2">
                    <input type="text" name="{$c}[title]" placeholder="请输入{$this->name}名称" class="required span5" value="{$a == 'edit' ? $result['title'] : ''}" />
                </td>
            </tr>
            <tr>
                <td>{$this->name}分类：</td>
                <td class="td2">
                    <select name="{$c}[sid]" class="sid">
                        <option value="0"{echo !$result['sid'] ? ' selected' : ''}>一级分类</option>
                    <!--{loop $this->sort $tree}-->
                        <!--{if $tree['id'] != $result['id']}-->
                        <option value="{$tree['id']}"{$tree['id'] == $result['sid'] ? ' selected' : ''}>{$tree['treeTitle']}</option>
                        <!--{/if}-->
                    <!--{/loop}-->
                    </select>
                </td>
            </tr>
            <tr>
                <td>{$this->name}内容：</td>
                <td class="td2">
                    <textarea name="{$c}[content]" id="message" style="width:100%;height:230px;">{$a == 'edit' ? htmlspecialchars_decode($result['content']) : ''}</textarea>
                    <script src="{$this->setting['weburl']}/content/editor/editor.js?v={echo time()}"></script>
                    <script>showEdit1( 1 );</script>
                </td>
            </tr>
            {template upload}
            <tr>
                <td>{$this->name}标签 ：</td>
                <td class="td2">
                    <input type="hidden" name="oldtag" value="{$result['tag']}" />
                    <input type="text" name="tag" class="span4" value="{$a == 'edit' ? $result['tag'] : ''}" />
                    <span class="lable">标签之间用英文,号隔开! 最多6个标签</span>
                </td>
            </tr>
            <tr>
                <td>{$this->name}{$this->type == 'link' ? '地址' : '别名'}：</td>
                <td class="td2">
                    <input type="text" name="{$c}[alias]" class="span4{$this->type == 'link' ? ' required' : ''}" value="{$a == 'edit' ? $result['alias'] : ''}" />
                </td>
            </tr>
            <tr>
                <td>发布时间：</td>
                <td class="td2">
                    <input type="text" id="dateline" name="{$c}[dateline]" value="{$a == 'edit' ? date($this->setting['timeformat'], $result['dateline']) : date($this->setting['timeformat'], time())}" readonly />
                    <span class="lable"><a href="" class="dateline btn btn-small">插入当前时间</a></span>
                </td>
            </tr>
            <tr>
                <td>{$this->name}排序 ：</td>
                <td class="td2">
                    <input type="text" name="{$c}[oid]" class="span1" value="{$a == 'edit' ? $result['oid'] : ''}" />
                    <span class="lable">数值越大越靠前显示</span>
                </td>
            </tr>
            <tr>
                <td>选项：</td>
                <td class="td2">
                    <label class="checkbox inline">
                        <input type="checkbox" name="{$c}[isTop]" value="1"{$a == 'edit' && $result['isTop'] ? 'checked' : ''} />置顶
                    </label>
                    <label class="checkbox inline">
                        <input type="checkbox" name="{$c}[isHide]" value="1"{$a == 'edit' && $result['isHide'] ? 'checked' : ''} />隐藏
                    </label>
                    <label class="checkbox inline">
                        <input type="checkbox" name="{$c}[isLock]" value="1"{$a == 'edit' && $result['isLock'] ? 'checked' : ''} />禁止评论
                    </label>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="td3">
                    <a title="保存{$this->name}" class="btn btn-success save_article" href="{$this->url($c,null, array('type' => $this->type))}">保 存</a>
                </td>
            </tr>
        </table>
    </form>

    <script type="text/javascript">
        $( function () {
            $( ".save_article" ).click( function () {
                var tagobj = $( 'input[name="tag[tagname]"]' );
                var tag = $.trim( tagobj.val() );
                if ( tag != '' && tag.indexOf( ',' ) != -1 ) {
                    var tags = tag.split( ',' );
                    if ( tags.length - 1 > 6 ) {
                        tagobj.next( 'span' ).addClass( 'error' );
                        tagobj.focus();
                        window.setTimeout( function () {
                            tagobj.next( 'span' ).removeClass( 'error' )
                        }, 3000 );
                        return false;
                    }
                }
                ajaxPOST( $( this ) );
                return false;
            });
        });
    </script>
    <!--{/if}-->
    </div>
{template footer}